﻿<UserControl x:Class="Gao.Poker.App.Game.GameEdit" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
             xmlns:Behaviours="clr-namespace:Gao.Poker.App.UserControls.Behaviours" mc:Ignorable="d">
    <ScrollViewer Margin="5" Grid.Column="1" Grid.Row="1">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="100" />
                <ColumnDefinition Width="300" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="30" />
                <RowDefinition Height="30" />
                <RowDefinition Height="100" />
                <RowDefinition Height="30" />
                <RowDefinition Height="30" />
                <RowDefinition Height="30" />
                <RowDefinition Height="*" />
                <RowDefinition Height="30" />
                <RowDefinition Height="30" />
                <RowDefinition Height="30" />
                <RowDefinition Height="50" />
            </Grid.RowDefinitions>

            <TextBlock Grid.Column="0" Grid.Row="0" Text="比赛名称：" Margin="1" VerticalAlignment="Center"
                       HorizontalAlignment="Right" />
            <TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Path=Competition.Name,Mode=TwoWay}" Margin="1"
                     Width="260" HorizontalAlignment="Left" VerticalContentAlignment="Center" />
            <Button Grid.Column="1" HorizontalAlignment="Right" Content="选择" Command="{Binding TemplateCommand}"
                    Style="{DynamicResource Green}" Margin="0,1,5,1" />

            <TextBlock Text="比赛时间：" Margin="1" VerticalAlignment="Center" Grid.Column="0" Grid.Row="1"
                       HorizontalAlignment="Right" />
            <DatePicker DisplayDate="{Binding Path=Competition.Date}" SelectedDate="{Binding Path=Competition.Date}"
                        Margin="1" VerticalContentAlignment="Center" Grid.Column="1" Grid.Row="1" />

            <TextBlock Text="选择桌号：" Grid.Column="0" Grid.Row="2" VerticalAlignment="Top" HorizontalAlignment="Right"
                       Margin="1" />
            <ListView Grid.Column="1" Grid.Row="2" Name="lvTables" Margin="1" Padding="0"
                      ItemsSource="{Binding Tableses}" SelectionMode="Multiple" VirtualizingStackPanel.VirtualizationMode="Recycling">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <Grid Margin="2">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <StackPanel Grid.Column="0" Grid.ColumnSpan="2" Margin="0">
                                <TextBlock FontWeight="Bold" Text="{Binding Path=Number}" />
                            </StackPanel>
                        </Grid>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>

            <TextBlock Text="购入筹码：" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="1" Grid.Column="0"
                       Grid.Row="3" />
            <TextBox Text="{Binding Path=Competition.Chips, Mode=TwoWay}" Margin="1" VerticalContentAlignment="Center"
                     Grid.Column="1" Grid.Row="3" />

            <TextBlock Grid.Column="0" Grid.Row="4" Text="对应积分：" VerticalAlignment="Center" HorizontalAlignment="Right"
                       Margin="1" />
            <TextBox Grid.Column="1" Grid.Row="4" Text="{Binding Path=Competition.SinglePoints , Mode=TwoWay}"
                     Margin="1" VerticalContentAlignment="Center" />

            <TextBlock Grid.Column="0" Grid.Row="5" Text="保底奖金：" VerticalAlignment="Center" HorizontalAlignment="Right"
                       Margin="1" />
            <TextBox Grid.Column="1" Grid.Row="5" Text="{Binding Path=Competition.DownsideBonus, Mode=TwoWay}"
                     Margin="1" VerticalContentAlignment="Center" />

            <TextBlock Grid.Column="0" Grid.Row="6" Text="比赛级别：" HorizontalAlignment="Right" Margin="1,2,1,1" />
            <!--<DataGrid Grid.Column="1" Grid.ColumnSpan="2"  Grid.Row="6"
                      Margin="1,2,1,1" Height="200" VerticalAlignment="Top" RowHeight="30" AutoGenerateColumns="False"
                      SelectionMode="Single"  CanUserAddRows="True"
                      ItemsSource="{Binding Path=Competition.CompetitionLevels, Mode=TwoWay}" FontSize="16">
                <DataGrid.Columns>
                    <DataGridTextColumn Header="级别" Width="40" Binding="{Binding Path=Level, Mode=TwoWay}"/>
                    <DataGridTextColumn Header="比赛时间" Width="80" Binding="{Binding Path=CompetitionTime, Mode=TwoWay}"/>
                    <DataGridTextColumn Header="盲注" Width="120" Binding="{Binding Path=Blind, Mode=TwoWay}"/>
                    <DataGridTextColumn Header="前置休息时间" Width="*" Binding="{Binding Path=AfterRestTime, Mode=TwoWay}"/>
                    <DataGridTextColumn Header="附加前注" Width="80" Binding="{Binding Path=AppendGamble, Mode=TwoWay}"/>
                </DataGrid.Columns>
            </DataGrid>-->

            <Button Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="6" HorizontalAlignment="Right" VerticalAlignment="Top" Height="30" Content="增加" 
                    Command="{Binding AddLevelCommand}" Style="{DynamicResource Green}" Margin="0,2,5,1" />
            <ListView Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="6" Margin="1,2,40,1" Height="200"
                      HorizontalAlignment="Stretch" Behaviours:GridViewColumnResize.Enabled="True" SelectionMode="Single"
                      ItemsSource="{Binding Path=Competition.CompetitionLevels, Mode=TwoWay}" FontSize="16">
                <ListView.ItemContainerStyle>
                    <Style TargetType="ListViewItem">
                        <Setter Property="HorizontalContentAlignment" Value="Right" />
                    </Style>
                </ListView.ItemContainerStyle>
                <ListView.View>
                    <GridView>
                        <GridViewColumn Header="级别" Width="60">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBox Text="{Binding Path=Level}" Width="40" Height="30"
                                             HorizontalAlignment="Stretch" VerticalContentAlignment="Center" HorizontalContentAlignment="Right" />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Header="比赛时间" Width="100">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBox Text="{Binding Path=CompetitionTime}" Width="80" Height="30"
                                             HorizontalAlignment="Stretch" VerticalContentAlignment="Center" HorizontalContentAlignment="Right" />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Header="盲注" Width="120">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBox Text="{Binding Path=Blind}" Width="100" Height="30"
                                             HorizontalAlignment="Stretch" VerticalContentAlignment="Center" HorizontalContentAlignment="Right" />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Header="前置休息时间" Width="100">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBox Text="{Binding Path=AfterRestTime}" Width="80" Height="30"
                                             HorizontalAlignment="Stretch" VerticalContentAlignment="Center" HorizontalContentAlignment="Right" />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Header="附加前注" Width="100">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBox Text="{Binding Path=AppendGamble}" Width="80" Height="30"
                                             HorizontalAlignment="Stretch" VerticalContentAlignment="Center" HorizontalContentAlignment="Right" />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                    </GridView>
                </ListView.View>
            </ListView>
           

            <!--<DataGrid Grid.Row="0" Grid.RowSpan="6" Grid.Column="2" Margin="20,1,10,1" RowHeight="30" Name="dgRight" 
                  SelectionMode="Single"  CanUserAddRows="True"  AutoGenerateColumns="False" 
                  ItemsSource="{Binding Path=Competition.Bounses, Mode=TwoWay}"
                  FontSize="16" Height="284">
                <DataGrid.Columns>
                    <DataGridTextColumn Header="名次" Width="60" Binding="{Binding Path=Rank, Mode=TwoWay}"/>
                    <DataGridTextColumn Header="奖金比例%" Width="*" Binding="{Binding Path=Scale, Mode=TwoWay}"/>
                </DataGrid.Columns>
            </DataGrid>-->
            
            <ListView Grid.Row="0" Grid.RowSpan="6" Grid.Column="2" Margin="20,1,40,1" Name="dgRight"
                      SelectionMode="Single" FontSize="16" Height="284" HorizontalAlignment="Stretch"
                      Behaviours:GridViewColumnResize.Enabled="True" ItemsSource="{Binding Path=Competition.Bounses, Mode=TwoWay}">
                <ListView.ItemContainerStyle>
                    <Style TargetType="ListViewItem">
                        <Setter Property="HorizontalContentAlignment" Value="Right" />
                    </Style>
                </ListView.ItemContainerStyle>
                <ListView.View>
                    <GridView>
                        <GridViewColumn Header="名次" Width="70">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBox Text="{Binding Path=Rank}" Width="50" Height="30"
                                             HorizontalAlignment="Stretch" VerticalContentAlignment="Center" HorizontalContentAlignment="Right" />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Header="奖金比例%" Width="180">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBox Text="{Binding Path=Scale}" Width="160" Height="30"
                                             HorizontalAlignment="Stretch" VerticalContentAlignment="Center" HorizontalContentAlignment="Right" />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                    </GridView>
                </ListView.View>
            </ListView>
            <Button Grid.Column="2" HorizontalAlignment="Right" Content="增加" Command="{Binding AddBounsCommand}"
                    Style="{DynamicResource Green}" Margin="0,1,5,1" />

            <TextBlock Grid.Column="0" Grid.Row="7" Text="比赛人数上限：" VerticalAlignment="Center"
                       HorizontalAlignment="Right" Margin="1" />
            <xctk:IntegerUpDown Grid.Column="1" Grid.Row="7" Value="{Binding Path=Competition.MaxMember, Mode=TwoWay}"
                                Text="10" Width="60" Margin="1" HorizontalAlignment="Left" VerticalContentAlignment="Center" />

            <TextBlock Grid.Column="0" Grid.Row="8" Text="管理费用比例：" VerticalAlignment="Center"
                       HorizontalAlignment="Right" Margin="1" />

            <StackPanel Grid.Column="1" Grid.Row="8" Orientation="Horizontal">
                <TextBox Text="{Binding Path=Competition.ManCastRatio, Mode=TwoWay}" Width="120" Margin="1"
                         VerticalContentAlignment="Center" />
                <TextBlock Text="%" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="1" />
            </StackPanel>

            <TextBlock Grid.Column="0" Grid.Row="9" Text="积分底数：" VerticalAlignment="Center" HorizontalAlignment="Right"
                       Margin="1" />
            <TextBox Grid.Column="1" Grid.Row="9" Width="120"
                     Text="{Binding Path=Competition.DownsidePoints, Mode=TwoWay}" Margin="1" HorizontalAlignment="Left"
                     VerticalContentAlignment="Center" />

            <StackPanel Orientation="Horizontal" Grid.ColumnSpan="2" Grid.Row="10" Margin="5"
                        VerticalAlignment="Center" HorizontalAlignment="Center">
                <Button Padding="5" Style="{DynamicResource Orrange}" Width="60" FontSize="16" Height="35"
                        Click="SaveCompetition_Click">保存</Button>
            </StackPanel>
        </Grid>
    </ScrollViewer>

</UserControl>
